package com.tom.feign.clients;

import com.tom.doc.CourseDoc;
import com.tom.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 降级类
 */
@Component
@Slf4j
public class FallbackFactorySystem implements FallbackFactory<CourseFeignClient> {


    @Override
    public CourseFeignClient create(Throwable throwable) {
        return new CourseFeignClient() {
            @Override
            public AjaxResult courseOnLine(CourseDoc doc) {
                return AjaxResult.me().setSuccess(false).setMessage("降级了兄弟");
            }

            @Override
            public AjaxResult courseOffLine(CourseDoc courseDoc) {
                return AjaxResult.me().setSuccess(false).setMessage("降级了兄弟");
            }
        };
    }
}
